<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Document Info and Metadata - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.pdf.info.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.pdf.info.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.pdf.interactive-features.html">Interactive Features</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.pdf.html">Zend_Pdf</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.pdf.usage.html">Zend_Pdf module usage example</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.pdf.info" class="section"><div class="info"><h1 class="title">Document Info and Metadata</h1></div>
    
    

    <p class="para">
        A <acronym class="acronym">PDF</acronym> document may include general information such as the document&#039;s
        title, author, and creation and modification dates.
    </p>

    <p class="para">
        Historically this information is stored using special Info structure. This structure
        is available for read and writing as an associative array using
        <span class="property">properties</span> public property of <span class="classname">Zend_Pdf</span> objects:
    </p>

    <pre class="programlisting brush: php">
$pdf = Zend_Pdf::load($pdfPath);

echo $pdf-&gt;properties[&#039;Title&#039;] . &quot;\n&quot;;
echo $pdf-&gt;properties[&#039;Author&#039;] . &quot;\n&quot;;

$pdf-&gt;properties[&#039;Title&#039;] = &#039;New Title.&#039;;
$pdf-&gt;save($pdfPath);
</pre>


    <p class="para">
        The following keys are defined by <acronym class="acronym">PDF</acronym> v1.4 (Acrobat 5) standard:

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Title</em> - string, optional, the document&#039;s title.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Author</em> - string, optional, the name of the person who
                    created the document.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Subject</em> - string, optional, the subject of the document.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Keywords</em> - string, optional, keywords associated with the
                    document.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Creator</em> - string, optional, if the document was converted
                    to <acronym class="acronym">PDF</acronym> from another format, the name of the application (for
                    example, Adobe FrameMaker®) that created the original document from which it was
                    converted.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Producer</em> - string, optional, if the document was converted
                    to <acronym class="acronym">PDF</acronym> from another format, the name of the application (for
                    example, Acrobat Distiller) that converted it to <acronym class="acronym">PDF</acronym>..
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">CreationDate</em> - string, optional, the date and time the
                    document was created, in the following form: &quot;D:YYYYMMDDHHmmSSOHH&#039;mm&#039;&quot;, where:

                    <ul class="itemizedlist">
                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">YYYY</em> is the year.
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">MM</em> is the month.
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">DD</em> is the day (01–31).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">HH</em> is the hour (00–23).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">mm</em>is the minute (00–59).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">SS</em> is the second (00–59).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">O</em> is the relationship of local time to
                                Universal Time (UT), denoted by one of the characters +, −, or Z
                                (see below).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">HH</em> followed by &#039; is the absolute value of the
                                offset from UT in hours (00–23).
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis">mm</em> followed by &#039; is the absolute value of the
                                offset from UT in minutes (00–59).
                            </p>
                        </li>
                    </ul>

                    The apostrophe character (&#039;) after HH and mm is part of the syntax. All fields
                    after the year are optional. (The prefix D:, although also optional, is strongly
                    recommended.) The default values for MM and DD are both 01; all other numerical
                    fields default to zero values. A plus sign (+) as the value of the O field
                    signifies that local time is later than UT, a minus sign (−) that local time is
                    earlier than UT, and the letter Z that local time is equal to UT. If no UT
                    information is specified, the relationship of the specified time to UT is
                    considered to be unknown. Whether or not the time zone is known, the rest of the
                    date should be specified in local time.
                </p>

                <p class="para">
                    For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is
                    represented by the string &quot;D:199812231952−08&#039;00&#039;&quot;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">ModDate</em> - string, optional, the date and time the document
                    was most recently modified, in the same form as
                    <em class="emphasis">CreationDate</em>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Trapped</em> - boolean, optional, indicates whether the document
                    has been modified to include trapping information.

                    <ul class="itemizedlist">
                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis"><b><tt>TRUE</tt></b></em> - The document has
                                been fully trapped; no further trapping is needed.
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis"><b><tt>FALSE</tt></b></em> - The document has
                                not yet been trapped; any desired trapping must still be done.
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                <em class="emphasis"><b><tt>NULL</tt></b></em> - Either it is
                                unknown whether the document has been trapped or it has been partly
                                but not yet fully trapped; some additional trapping may still be
                                needed.
                            </p>
                        </li>
                    </ul>
                </p>
            </li>
        </ul>
    </p>

    <p class="para">
        Since <acronym class="acronym">PDF</acronym> v 1.6 metadata can be stored in the special
        <acronym class="acronym">XML</acronym> document attached to the <acronym class="acronym">PDF</acronym> (XMP - <a href="http://www.adobe.com/products/xmp/" class="link external">&raquo; Extensible Metadata Platform</a>).
    </p>

    <p class="para">
        This <acronym class="acronym">XML</acronym> document can be retrieved and attached to the PDF with
         <span class="methodname">Zend_Pdf::getMetadata()</span> and
         <span class="methodname">Zend_Pdf::setMetadata($metadata)</span> methods:
    </p>

    <pre class="programlisting brush: php">
$pdf = Zend_Pdf::load($pdfPath);
$metadata = $pdf-&gt;getMetadata();
$metadataDOM = new DOMDocument();
$metadataDOM-&gt;loadXML($metadata);

$xpath = new DOMXPath($metadataDOM);
$pdfPreffixNamespaceURI = $xpath-&gt;query(&#039;/rdf:RDF/rdf:Description&#039;)
                                -&gt;item(0)
                                -&gt;lookupNamespaceURI(&#039;pdf&#039;);
$xpath-&gt;registerNamespace(&#039;pdf&#039;, $pdfPreffixNamespaceURI);

$titleNode = $xpath-&gt;query(&#039;/rdf:RDF/rdf:Description/pdf:Title&#039;)-&gt;item(0);
$title = $titleNode-&gt;nodeValue;
...

$titleNode-&gt;nodeValue = &#039;New title&#039;;
$pdf-&gt;setMetadata($metadataDOM-&gt;saveXML());
$pdf-&gt;save($pdfPath);
</pre>


    <p class="para">
        Common document properties are duplicated in the Info structure and Metadata document (if
        presented). It&#039;s user application responsibility now to keep them synchronized.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.pdf.interactive-features.html">Interactive Features</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.pdf.html">Zend_Pdf</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.pdf.usage.html">Zend_Pdf module usage example</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.pdf.html">Zend_Pdf</a></li>
  <li><a href="zend.pdf.introduction.html">Introduction</a></li>
  <li><a href="zend.pdf.create.html">Creating and Loading PDF Documents</a></li>
  <li><a href="zend.pdf.save.html">Save Changes to PDF Documents</a></li>
  <li><a href="zend.pdf.pages.html">Working with Pages</a></li>
  <li><a href="zend.pdf.drawing.html">Drawing</a></li>
  <li><a href="zend.pdf.interactive-features.html">Interactive Features</a></li>
  <li class="active"><a href="zend.pdf.info.html">Document Info and Metadata</a></li>
  <li><a href="zend.pdf.usage.html">Zend_Pdf module usage example</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>